﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CSP.Model.Entities;
using CSP.Model.Model;

namespace CSP.Model.Presenter
{
    public class FollowerRequestsPresenter
    {
        private IFollowerRequestsPresenter view = null;
        private ModelManager model = new ModelManager();

        public FollowerRequestsPresenter(IFollowerRequestsPresenter iView)
        {
            view = iView;
        }

        public void Load()
        {
            try
            {
                BindFollowerRequests();
                model.CheckForNewColleagues();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void BindFollowerRequests()
        {
            try
            {
                List<FollowerRequest> requests = model.GetFollowerRequests(view.MyListName);
                view.BindFollowerRequests(requests);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public void rejectRequest(string followerId)
        {
            model.rejectRequest(view.MyListName, followerId);
            BindFollowerRequests();
        }

        public void approveRequest(string followerId)
        {
            model.approveRequest(view.MyListName, followerId);
            BindFollowerRequests();
        }
    }
}
